import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Header from '../components/Header.vue'
import Privese from '../views/Privese.vue'
import Explore from '../views/Explore.vue'
import CatPrivese from '../views/CatPrivese.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Message from '../views/Message.vue'
import Users from '../views/Users.vue'
import Setting from '../views/Setting.vue'
import SettingPassword from '../views/SettingPassword.vue'
import SettingUserName from '../views/SettingUserName.vue'

Vue.use(VueRouter)

const routes = [
    { path: '/', redirect: '/header' },
    { 
      path: '/header', component: Header, redirect: '/home',
      children: [
        { path: '/home', component: Home },
        { path: '/privese/:id', component: Privese },
        { path: '/explore', component: Explore },
        { path: '/catPrivese/:id', component: CatPrivese },
        { path: '/login', component: Login },
        { path: '/register', component: Register },
        { path: '/message', component: Message },
        { path: '/users', component: Users },
        { path: '/setting', component: Setting },
        { path: '/setting/password', component: SettingPassword },
        { path: '/setting/userName', component: SettingUserName },
      ]
    }, 
]

const router = new VueRouter({
  routes
})


const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error=> error)
}

export default router
